﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;

namespace Accumulation.Controls.Menu {
    public class MenuItemPluses : CollectionBase, IStateManager {
        private bool _isTrackingViewState;

        public MenuItemPluses() : base() { }

        public MenuItemPlus this[int index] {
            get { return (MenuItemPlus)base.List[index]; }
            set { base.List[index] = value; }
        }

        public void Add(MenuItemPlus mi) {
            base.List.Add(mi);
        }

        public void Remove(int index) {
            if (index < base.Count - 1 && index > 0) {
                base.List.Remove(index);
            }
        }

        #region Implement IStateManager interface

        bool IStateManager.IsTrackingViewState {
            get { return this._isTrackingViewState; }
        }

        void IStateManager.LoadViewState(object state) {
            if (state != null) {
                object[] viewState = (object[])state;
                for (int i = 0; i < viewState.Length; i++) {
                    ((IStateManager)base.List[i]).LoadViewState(viewState[i]);
                }
            }
        }

        object IStateManager.SaveViewState() {
            object[] iState = new object[base.List.Count];
            for (int i = 0; i < base.List.Count; i++) {
                iState[i] = ((IStateManager)base.List[i]).SaveViewState();
            }
            return iState;
        }

        void IStateManager.TrackViewState() {
            this._isTrackingViewState = true;
            for (int i = 0; i < base.List.Count; i++) {
                ((IStateManager)base.List[i]).TrackViewState();
            }
        }

        #endregion
    }
}
